let menuList = [{
  label: '首页',
  path: '/home'
},
{
  label: '学校管理',
  children: [{
    label: '学校开通',
    path: '/school/open'
  }, {
    label: '学校查询',
    path: '/school/search'
  }]
}, {
  label: '评测管理',
  children: [{
    label: '因素管理',
    path: '/evaluate/factor'
  }, {
    label: '添加因素',
    path: '/evaluate/factorAdd'
  }, {
    label: '题库管理',
    path: '/evaluate/questionBank'
  }, {
    label: '报告管理',
    path: '/evaluate/reportBank'
  }, {
    label: '添加报告',
    path: '/evaluate/reportAdd'
  }, {
    label: '添加题目',
    path: '/evaluate/topicAdd'
  }, {
    label: '题目管理',
    path: '/evaluate/topicBank'
  }]
}]

let routerPath = {};
menuList.forEach((item, index) => {
  item.index = index;
  if (item.path) {
    pushBreadcrumb(item)
  } else {
    item.children.forEach((el, idx) => {
      el.index = idx;
      pushBreadcrumb(el, item)
    })
  }
})

function pushBreadcrumb (opts, parent) {
  let key = opts.path.match(/[a-zA-Z]+/g).join('_')
  routerPath[key] = {'breadcrumb': [], index: []};
  if (parent) {
    routerPath[key]['breadcrumb'].push(parent.label)
    routerPath[key]['index'].push(parent.index)
  }
  routerPath[key]['breadcrumb'].push(opts.label)
  routerPath[key]['index'].push(opts.index)
}

export { menuList, routerPath }
